
$(document).ready(function () {
    // 登录邮箱合法性提醒
    var $email = $("#email");
    $email.focusout(function() {
        // debugger;
        var emailText = $email.val();
        // console.log(emailText);
        if (checkEmail(emailText) == false) {
            toastr.warning('请输入合法的邮箱');
            $email.focus();
            return;
        }
    });

    // 注册邮箱合法性提醒
    var $email_ = $("#email_");
    $email_.focusout(function() {
        // debugger;

        var emailText = $email_.val();
        // console.log(emailText);
        if (checkEmail(emailText) == false) {
            toastr.warning('请输入合法的邮箱');
            $email_.focus();
            return;
        }
    });

    // 注册确认密码一致提醒
    var $confirmPassword_ = $("#confirmPassword_");
    var $password_ = $("#password_");

    $confirmPassword_.focusout(function () {
        if ($confirmPassword_.val() != $password_.val()) {
            toastr.warning('确认密码与密码不一致');
            $password_.focus();
            return;
        }
    });

});

// 邮箱校验
function checkEmail(email) {
    var emailReg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
    if (!emailReg.test(email)) {
        return false;
    }
    return true;
}
